package com.bwie.a0522_chenzihang.Adapter;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.bwie.a0522_chenzihang.Fragments.AboutFragment;
import com.bwie.a0522_chenzihang.Fragments.BookFragment;
import com.bwie.a0522_chenzihang.Fragments.MeFragment;
import com.bwie.a0522_chenzihang.MainActivity;


public class MyFragmentPagerAdapter extends FragmentPagerAdapter {
    private int PAGER_COUNT=3;
    private BookFragment bookFragment=null;
    private AboutFragment aboutFragment=null;
    private MeFragment meFragment=null;
    public MyFragmentPagerAdapter(@NonNull FragmentManager fm) {
        super(fm);
        bookFragment=new BookFragment();
        aboutFragment=new AboutFragment();
        meFragment=new MeFragment();
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        Fragment fragment=null;
        switch (position) {
            case MainActivity.PAGE_ONE:
                fragment=bookFragment;
                break;
            case MainActivity.PAGE_TWO:
                fragment=aboutFragment;
                break;
            case MainActivity.PAGE_THREE:
                fragment=meFragment;
                break;
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return PAGER_COUNT;
    }
}